"use client";
import Box from "@/components/Box";
import Header from "@/components/Header";
import { usePathname } from "@/i18n";
import { FC, PropsWithChildren, ReactNode, useEffect, useRef } from "react";
type Props = {
    swiperWidget: ReactNode;
    popupWidget: ReactNode;
    cardWidget: ReactNode;
    noticeWidget: ReactNode;
    searchWidget: ReactNode;
    prizeWidget: ReactNode;
};
const Layout: FC<PropsWithChildren<Props>> = (props) => {
    const {
        children,
        swiperWidget,
        popupWidget,
        cardWidget,
        noticeWidget,
        searchWidget,
        prizeWidget,
        ...other
    } = props;
    const barRef = useRef<HTMLDivElement>(null);

    // 获取分享id
    const pathname = usePathname();
    useEffect(() => {
        const [, shareId] = pathname.split("/");
        if (!shareId || shareId === "xxxxxx") return;
        sessionStorage.setItem("shareId", shareId);
    }, []);
    return (
        <>
            <Header {...other}></Header>
            <main id="maincontainer" className={"main-footer-header"}>
                {/*弹窗*/}
                {popupWidget}
                <Box>
                    {/* swiper */}
                    {swiperWidget}
                    {/* swiper下的活动 */}
                    {cardWidget}
                    {/* 跑马灯 */}
                    {noticeWidget}
                    {/* 搜索组件 */}
                    {searchWidget}
                    {/* 搜索下面的大奖展示 */}
                    {prizeWidget}
                </Box>
                {/* tabs 和 游戏列表 */}
                {children}
            </main>
        </>
    );
};

export default Layout;
